/***********************************************************************************/
/* Code license:  GNU General Public License v3                                    */
/* Main page:     https://code.google.com/p/library-cross-platform/                */
/* Issue tracker: https://code.google.com/p/library-cross-platform/issues/list     */
/***********************************************************************************/

#include "hash.h"
#include "string.h"

static unsigned long gethvalue(const unsigned char, unsigned long);

inline unsigned long gethvalue(const unsigned char ucv, unsigned long base)
{
  unsigned long ret = 1;
  unsigned long offset = ucv - 'a';
  ret = ret << offset;
  ret = base | ret;
  return ret;
}


unsigned long getHashStringValue( char const *pch )
{
  int str_size = strlen(pch);
  int count = 0;
  unsigned long ret = 0;

  while(count < str_size)
  {
    ret += gethvalue(pch[count], ret);
    count ++;
  }

  return ret;
}

